package com.example.day1.photoWall;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.example.day1.R;


public class PhotoAdapter extends BaseAdapter {
    Context context;
    //数据源
    String[]mDatas;

    public PhotoAdapter(Context context, String[] mDatas) {
        this.context = context;
        this.mDatas = mDatas;
    }


    @Override
    public int getCount() {//返回条目的数量
        return mDatas.length;
    }

    @Override
    public Object getItem(int position) {//返回指定位置的数据
        return mDatas[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if (convertView == null) {
            convertView= LayoutInflater.from(context).inflate(R.layout.item_photowall,null);
            holder=new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder= (ViewHolder) convertView.getTag();
        }
        String url = mDatas[position];
        //使用毕加索加载图片
      ;
        return convertView;
    }
    class ViewHolder{
        ImageView iv;
        public ViewHolder(View view){
            iv=view.findViewById(R.id.item_photowall_iv);
        }
    }
}